package ltd.dujiabao.inventoryservice.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @author Bowie Du
 * @date 2025/7/26 19:50
 */
@LocalTCC
public interface InventoryTccService {
    @TwoPhaseBusinessAction(name = "deductStock", commitMethod = "commit", rollbackMethod = "rollback")
    void deductStock(@BusinessActionContextParameter(paramName = "productId") Long productId,
                     @BusinessActionContextParameter(paramName = "quantity") Integer quantity);

    boolean commit(BusinessActionContext context);

    boolean rollback(BusinessActionContext context);
}
